package com.runjian.rundo.iot.agent.iec104.parser.frame;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;
import lombok.Setter;

/**
 * 双点遥控信息 命令类型 0.遥控执行命令 1.遥控选择命令 开关状态 0.不允许，有错误 1.开关分 2.开关合 3.不允许，有错误
 * 
 * @author CaoQingHua
 */
@Getter
@Setter
public class DoublePointRemoteControl extends PointRemoteControl {

    public DoublePointRemoteControl(byte data) {
        super((data & 0xff & 0x80) == 128, (data & 0xff & 0x03));
    }

    public DoublePointRemoteControl(boolean type, int status) {
        super(type, status);
    }

    public Boolean validate() {
        return !(getStatus() >= 3 || getStatus() <= 0);
    }

    @Override
    public String console() {
        return StrUtil.format("遥控双点对象: {}   {}", isType() ? "遥控选择指令" : "遥控执行指令", getStatusStr());
    }

    @Override
    public String getStatusStr() {
        switch (this.getStatus()) {
            case 1:
                return "开关分";
            case 2:
                return "开关合";
            case 3:
            case 0:
                return "不允许，有错误";
        }
        return "";
    }

}
